<template>
  <div class="search">
    <f-drawer ref="bmpUpdateDrawer" :title="drawerTitle" width="90%" @submit="handleSubmit" @visibleChange="visibleChange" :showFooter="false">
      <a-tabs @tabClick="tabClick" :defaultActiveKey="current" v-model="current">
        <a-tab-pane :tab="drawerTitle" key="update_list" v-if="showType == 1">
          <bmp-update-list ref="update_list" v-if="drawerVisible" :detailsParams="detailsParams"></bmp-update-list>
        </a-tab-pane>
        <a-tab-pane :tab="drawerTitle" key="add_list" v-if="showType == 2">
          <bmp-add-list ref="add_list" v-if="drawerVisible" :detailsParams="detailsParams"></bmp-add-list>
        </a-tab-pane>
      </a-tabs>
    </f-drawer>
  </div>
</template>
<script>
  import bmpUpdateList from './bmp_update_list.vue'
  import bmpAddList from './bmp_add_list.vue'
  export default {
    name: 'bmpUpdateDrawer',
    components: { bmpUpdateList, bmpAddList },
    props: {
      listType: {
        type: Number,
        default: 1
      },
      detailsParams:{}
    },
    data() {
      return {
        refs: this.$refs,
        drawerVisible: false,
        showType: 0,
        title: '',
        current: 'update_list',
        formData: {},
        forms: [
          'update_list'
        ]
      }
    },
    methods: {
      showDrawer(listType) {
        if (listType === 1) {
          this.showType = listType
          this.tabClick('update_list')
        } else if (listType === 2) {
          this.showType = listType
          this.tabClick('add_list')
        }
        this.refs['bmpUpdateDrawer'].show()
      },
      handleSubmit(callback) {
        //this.refs[this.current].handleSubmit(callback)
      },
      visibleChange(drawerVisible) {
        this.drawerVisible = drawerVisible
      },
      tabClick(name) {
        this.current = name
        if (this.current === 'update_list') {
          this.title = '修正计划'
        } else if (this.current === 'add_list') {
          this.title = '追加变更'
        }
      }
    },
    computed: {
      drawerTitle: function() {
        return this.title
      }
    },
    created() {
    }
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
